/*
 * 借货新建的时候带出 并购公司计划单价 和 价格体系的市场报价
 */
public class BorrowGoodsDetailHandler
{
    public static void bringPrice(List<BorrowGoodsDetail__c> list_new)
    {
        ///查询当前用户
        User u = [select SubCompany__c from User where Id =:UserInfo.getUserId()];
       ///查询产品
        Map<String,BorrowGoodsDetail__c> bgdMap = new Map<String,BorrowGoodsDetail__c>();
        
        for(BorrowGoodsDetail__c bgd : list_new){
        	if(bgd.Inventory__c != null){
                bgdMap.put(bgd.Inventory__c,bgd);
            }
        
        }
        
        ///从价格体系中查询价格
        for(Price__c pr : [select InstCost__c,MarketPrice__c ,Product__c
                        from Price__c where Company__c=:u.SubCompany__c and Product__c in:bgdMap.keySet()]){
        
        	if(bgdMap.containsKey(pr.Product__c)){
            	BorrowGoodsDetail__c bgd = bgdMap.get(pr.Product__c);
                bgd.InstCost__c = pr.InstCost__c;
                bgd.Price__c = pr.MarketPrice__c;
            }
        }
        
      
        
    }
}